package me.mcx.mcx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import me.mcx.common.annotation.Log;
import me.mcx.common.core.controller.BaseController;
import me.mcx.common.core.domain.AjaxResult;
import me.mcx.common.core.page.TableDataInfo;
import me.mcx.common.enums.BusinessType;
import me.mcx.common.utils.poi.ExcelUtil;
import me.mcx.mcx.domain.McxCourse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import me.mcx.mcx.service.IMcxCourseService;

/**
 * 发展历程Controller
 * 
 * @author mcx
 * @date 2024-09-21
 */
@RestController
@RequestMapping("/mcx/course")
public class McxCourseController extends BaseController
{
    @Autowired
    private IMcxCourseService mcxCourseService;

    /**
     * 查询发展历程列表
     */
    @PreAuthorize("@ss.hasPermi('mcx:course:list')")
    @GetMapping("/list")
    public TableDataInfo list(McxCourse mcxCourse)
    {
        startPage();
        List<McxCourse> list = mcxCourseService.selectMcxCourseList(mcxCourse);
        return getDataTable(list);
    }

    /**
     * 导出发展历程列表
     */
    @PreAuthorize("@ss.hasPermi('mcx:course:export')")
    @Log(title = "发展历程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, McxCourse mcxCourse)
    {
        List<McxCourse> list = mcxCourseService.selectMcxCourseList(mcxCourse);
        ExcelUtil<McxCourse> util = new ExcelUtil<McxCourse>(McxCourse.class);
        util.exportExcel(response, list, "发展历程数据");
    }

    /**
     * 获取发展历程详细信息
     */
    @PreAuthorize("@ss.hasPermi('mcx:course:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mcxCourseService.selectMcxCourseById(id));
    }

    /**
     * 新增发展历程
     */
    @PreAuthorize("@ss.hasPermi('mcx:course:add')")
    @Log(title = "发展历程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody McxCourse mcxCourse)
    {
        return toAjax(mcxCourseService.insertMcxCourse(mcxCourse));
    }

    /**
     * 修改发展历程
     */
    @PreAuthorize("@ss.hasPermi('mcx:course:edit')")
    @Log(title = "发展历程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody McxCourse mcxCourse)
    {
        return toAjax(mcxCourseService.updateMcxCourse(mcxCourse));
    }

    /**
     * 删除发展历程
     */
    @PreAuthorize("@ss.hasPermi('mcx:course:remove')")
    @Log(title = "发展历程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mcxCourseService.deleteMcxCourseByIds(ids));
    }
}
